package com.elinkway.infinitemovies.bigdata;

import android.content.Context;
import android.content.SharedPreferences;

public class BigDataPreference {
    
    public static final String BIGDATA ="bigdata";
    public static final String AUID ="auid";
    public static final String MAC ="mac";
    public static final String CACHE ="cache";
    public static final String ENV_REPORT_DATE ="env_report_date";
    private Context context;
    private static BigDataPreference instance;
    private BigDataPreference(Context context){
        this.context = context;
    }
    public static void init(Context context){
        instance = new BigDataPreference(context);
    }
    public void putString(String key, String value){
        checkContext();
        SharedPreferences sp = context.getSharedPreferences(BIGDATA, Context.MODE_PRIVATE);
        sp.edit().putString(key, value).commit();
    }
    public String getString(String key){
        checkContext();
        SharedPreferences sp = context.getSharedPreferences(BIGDATA, Context.MODE_PRIVATE);
        return sp.getString(key, "");
    }
    private void checkContext(){
        if(null == context){
            throw new IllegalStateException("not yet init, call init(Context context) first.");
        }
    }
    public static BigDataPreference getInstance() {
        return instance;
    }
}
